home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 July: Mac OS SDK / Dev.CD Jul 97 SDK1.toast / Development Kits (Disc 1) / QuickDraw GX / Programming Stuff / Sample Code / Printing Samples / Printer Drivers… / ImageWriter / OldApp.c < prev    next >
Encoding:
Text File  |  1996-06-15  |  18.2 KB  |  659 lines  |  [TEXT/MPS ]

  1. /*
  2.     copyright © 1992-1994 Apple Computer Inc.  All rights reserved.
  3.     
  4.     OldApp.c
  5.     This file implements old application message overrides for the specific driver.
  6.     
  7.     Included in this file is the old PrintRecord emulation.  Note that the ImageWriter
  8.     PrintRecord is a wonder of misdirection and special cases.  You'll have fun
  9.     figuring out the code - so unless you really want to exactly emulate the ImageWriter
  10.     pages, you shouldn't spend too much time looking at this code.
  11.     
  12.     Modification history
  13.     7/23/92            TED                New file today
  14.     12/20/93        dmh                Sync'd with the shipping 1.0b3 GX driver.
  15.      8/26/94        dmh                Sync'd with the shipping 1.0.1 GX driver.
  16.      6/14/96        cn                Updated to support Universal Interfaces 2.1.
  17.  
  18. */
  19.  
  20. // Include the standard Mac header files 
  21. #include <Errors.h>
  22. #include <ToolUtils.h>
  23. #include <StdIO.h>
  24. #include <StdLib.h>
  25. #include <String.h>
  26. #include <Strings.h>
  27. #include <Resources.h>
  28. #include <ToolUtils.h>
  29. #include <OSUtils.h>
  30. #include <Files.h>
  31. #include <Types.h>
  32. #include <Packages.h>
  33. #include <Memory.h>
  34. #include <Serial.h>
  35. #include <Devices.h>
  36. #include <Fonts.h>
  37. #include <Printing.h>
  38. #include <Script.h>
  39. #include <Events.h>
  40. #include <Dialogs.h>
  41. #include <FixMath.h>
  42. #include <Lists.h>
  43. #include <AppleTalk.h>
  44. #include <Menus.h>
  45. #include <Events.h>
  46. #include <Balloons.h>
  47. #include <Folders.h>
  48. #include <SCSI.h>
  49.  
  50. // Include the new QuickDraw GX graphics header files 
  51. #include <GXGraphics.h>
  52. #include <GraphicsLibraries.h>
  53. #include <GXMath.h>
  54. #include <QDLibrary.h>
  55. #include <FontLibrary.h>
  56. #include <GXLayout.h>
  57.  
  58. // Include the required Printing Manager header files 
  59. #include <GXPrinting.h>
  60. #include <GXPrinterDrivers.h>
  61. #include <Collections.h>
  62. #include <GXMessages.h>
  63. #include <PrintingLibraries.h>
  64.  
  65. #include <GXExceptions.h>
  66.  
  67. #include "CommonDefines.h"            // things common to .r and .h files
  68.  
  69. /* ----------------------------------------------------------------------------    */
  70. /* INTERNAL TYPEDEFS AND STRUCTURES                                                */
  71. /* ----------------------------------------------------------------------------    */
  72. // ImageWriter wDev values
  73. #define kBest            0x01
  74. #define kPortrait        0x02
  75. #define kTallAdjusted    0x04
  76. #define k50Percent        0x08
  77. #define kNoGaps            0x10
  78. #define kSetResCalled    0x20
  79.  
  80. // some ImageWriter constants
  81. #define kGapSize        60        // gap at top of page in 120ths of an inch
  82. #define kSmallPlaten    16        // platen width in half inches for small IW
  83. #define kBigPlaten        27        // platen width in half inches for the 15" IW
  84.  
  85. /* ----------------------------------------------------------------------------    */
  86. /* FORWARD DECLARES                                                                */
  87. /* ----------------------------------------------------------------------------    */
  88. OSErr SD_ConvertPrintRecordTo(THPrint hoPrint);
  89. OSErr SD_ConvertPrintRecordFrom(gxUniversalPrintRecordHdl huPrint);
  90.  
  91.  
  92. /* ----------------------------------------------------------------------------    */
  93. /* INTERNAL ROUTINES                                                            */
  94. /* ----------------------------------------------------------------------------    */
  95. OSErr    UpdatePrintRecord(THPrint hPrint)
  96. {
  97.     OSErr                        anErr;
  98.     gxUniversalPrintRecordHdl     huPrint = (gxUniversalPrintRecordHdl) hPrint;
  99.     gxUniversalPrintRecordPtr     puPrint;
  100.     short                        devVRes, devHRes, appVRes, appHRes;
  101.     short                        cPlaten;
  102.     
  103.     // convert to universal format
  104.     anErr = SD_ConvertPrintRecordTo(hPrint);
  105.     if (anErr == noErr)
  106.         {
  107.         // determine application & device resolutions, based upon quality mode, tall adjusted
  108.         // setting, and if the app called SetRsl:
  109.         //    draft - 80(h)*72(v)
  110.         //    faster - 80(h)*72(v)
  111.         //    best - 160(h)*144(v)
  112.         //
  113.         //    draft (tall adjusted) - 72*72
  114.         //    faster (tall adjusted) - 72*72
  115.         //    best (tall adjusted) - 144*144
  116.         
  117.         puPrint = *huPrint;
  118.         if (puPrint->options & gxPreciseBitmap)
  119.             switch(puPrint->qualityMode)
  120.                 {
  121.                 case gxDraftQuality:
  122.                 case gxFasterQuality:
  123.                     devVRes = devHRes = 72;
  124.                     appVRes = appHRes = 72;
  125.                     break;
  126.                     
  127.                 case gxBestQuality:
  128.                     devVRes = devHRes = 144;
  129.                     appVRes = appHRes = 72;
  130.                     break;
  131.                 }
  132.         else
  133.             switch(puPrint->qualityMode)
  134.                 {
  135.                 case gxDraftQuality:
  136.                 case gxFasterQuality:
  137.                     appVRes = devVRes = 72;
  138.                     appHRes = devHRes = 80;
  139.                     break;
  140.                     
  141.                 case gxBestQuality:
  142.                     devVRes = 144;
  143.                     devHRes = 160;
  144.                     appVRes = 72;
  145.                     appHRes = 80;
  146.                     break;
  147.                 }
  148.             
  149.         // SetRsl was called?  Use the resolution specified by the application
  150.         if (puPrint->appVRes != 72)
  151.             {
  152.             appVRes = devVRes = puPrint->appVRes;
  153.             appHRes = devHRes = puPrint->appHRes;
  154.             }
  155.             
  156.         // finally, store the app & device resolutions
  157.         puPrint->devVRes = devVRes;
  158.         puPrint->devHRes = devHRes;
  159.         puPrint->appVRes = appVRes;
  160.         puPrint->appHRes = appHRes;
  161.         
  162.         // here we do page size calculations
  163.         // Please note that this code is confusing - it's purpose is to emulate
  164.         // the existing ImageWriter driver's page size.  Most drivers would not
  165.         // do this - the existing in the system probably is good enough.
  166.         {
  167.         long        pageGap;                // gap at top of page
  168.         long        dvPaper, dhPaper;        // paper size at device res
  169.         long        dvPage, dhPage;            // page size at device res
  170.         long        scanLines, scanBits;    // # of scan lines or bits on page
  171.         long        maxH;                    // maximum width
  172.         long        hOff, vOff;                // margins (horiz & vert) to get paper rect from page rect
  173.         
  174.         // gap at the top of the page in pixels
  175.         pageGap = (kGapSize * appVRes) / 120;
  176.         if (puPrint->options & gxBiggerPages)
  177.             pageGap = 0;
  178.             
  179.         // figure out paper size in application space pixels
  180.         dvPaper = (puPrint->pageV * appVRes) / 120;
  181.         dhPaper = (puPrint->pageH * appHRes) / 120;
  182.                 
  183.         // vertically, align to the head height of 8 pixels
  184.         scanLines = ((dvPaper - pageGap) >> 3) << 3;
  185.         
  186.         // horizontally, allow the biggest width we can handle
  187.         cPlaten = kSmallPlaten;
  188.         if (puPrint->pageH > (9*120) )
  189.             cPlaten = kBigPlaten;
  190.             
  191.         maxH = (cPlaten * appHRes) >> 1;
  192.         if (maxH > dhPaper)
  193.             maxH = dhPaper;
  194.         scanBits = (maxH >> 4) << 4;
  195.         
  196.         if (puPrint->orientation == gxPortraitOrientation)
  197.             {
  198.             // portrait
  199.             
  200.             dhPage = scanBits;
  201.             dvPage = scanLines;
  202.             
  203.             hOff = (dhPage - dhPaper) >> 1;
  204.             vOff = -pageGap;
  205.             }
  206.         else
  207.             {
  208.             // landscape
  209.             
  210.             dhPage = scanLines;
  211.             dvPage = scanBits;
  212.             
  213.             // reverse the paper definition as well
  214.             {
  215.             long iTemp = dhPaper;
  216.             dhPaper = dvPaper;
  217.             dvPaper = iTemp;
  218.             }
  219.             
  220.             hOff = -pageGap;
  221.             vOff = (dvPage - dvPaper) >> 1;
  222.             }
  223.             
  224.         // 50% reduction?  scale everything by 2X
  225.         if (puPrint->options & gxUserFlag0)
  226.             {
  227.             dhPage <<= 1;
  228.             dvPage <<= 1;
  229.             dhPaper <<= 1;
  230.             dvPaper <<= 1;
  231.             hOff <<= 1;
  232.             vOff <<= 1;
  233.             }
  234.             
  235.         // set the page and paper in app space
  236.         puPrint->appPage.left         = puPrint->appPage.top = 0;
  237.         puPrint->appPage.right         = dhPage;
  238.         puPrint->appPage.bottom     = dvPage;
  239.         
  240.         puPrint->appPaper.left         = hOff;
  241.         puPrint->appPaper.top         = vOff;
  242.         puPrint->appPaper.right     = dhPaper + hOff;
  243.         puPrint->appPaper.bottom     = dvPaper + vOff;
  244.                 
  245.         // from page, scale up to device space (in case some weenie decides to look at that)
  246.         puPrint->devPage.left         = puPrint->devPage.top = 0;
  247.         puPrint->devPage.right         = dhPage * devHRes / appHRes;
  248.         puPrint->devPage.bottom     = dvPage * devVRes / appVRes;
  249.         }
  250.         
  251.         // convert back to non-universal format
  252.         anErr = SD_ConvertPrintRecordFrom((gxUniversalPrintRecordHdl) hPrint);
  253.         }
  254.         
  255.     return(anErr);
  256.     
  257. } // UpdatePrintRecord
  258.  
  259. //<FF>
  260. /* ----------------------------------------------------------------------------    */
  261. /* MESSAGE OVERRIDES                                                            */
  262. /* ----------------------------------------------------------------------------    */
  263. OSErr SD_ConvertPrintRecordTo(THPrint hoPrint)
  264. /*
  265.     This call takes a print record in old style (driver specific) format, and
  266.     converts it to the format of "gxUniversalPrintRecordHdl"
  267. */
  268. {
  269.     TPPrint                        poPrint;            // pointer to old style print record
  270.     gxUniversalPrintRecordHdl    huPrint = (gxUniversalPrintRecordHdl) hoPrint;    // handle to universal print record
  271.     gxUniversalPrintRecordPtr    puPrint;            // pointer to universal print record
  272.     short                        qualityMode;        // cached quality mode
  273.     short                        wDev;                // cached wDev
  274.     
  275.     // cache pointers for size and speed
  276.     puPrint = *huPrint;
  277.     poPrint = *hoPrint;
  278.     wDev = poPrint->prStl.wDev;
  279.     
  280.     // determine quality mode
  281.     if (poPrint->prJob.bJDocLoop == 0)
  282.         qualityMode = gxDraftQuality;
  283.     else
  284.         {
  285.         if (wDev & kBest)
  286.             qualityMode = gxBestQuality;
  287.         else
  288.             qualityMode = gxFasterQuality;
  289.         }
  290.         
  291.     // universal feed is the inverse of our feed
  292.     puPrint->feed            =    1-(poPrint->prStl.feed);
  293.     
  294.     // wDev 0x02 means portrait, else landscape
  295.     if (wDev & kPortrait) 
  296.         puPrint->orientation    =    gxPortraitOrientation;
  297.     else
  298.         {
  299.         puPrint->orientation    =    gxLandscapeOrientation;
  300.         
  301.         // landscape disabled draft, forces tall adjusted
  302.         if (qualityMode == gxDraftQuality)
  303.             qualityMode = gxFasterQuality;
  304.         wDev |= kTallAdjusted;
  305.         }
  306.         
  307.     // copies are in iCopies field (wow.)
  308.     puPrint->actualCopies        =    poPrint->prJob.iCopies;
  309.     
  310.     // store our flags
  311.     puPrint->options = 0;
  312.     
  313.     // tall adjusted
  314.     if (wDev & kTallAdjusted) 
  315.         puPrint->options |= gxPreciseBitmap;
  316.         
  317.     // 50% reduction
  318.     if (wDev & k50Percent) 
  319.         {
  320.         puPrint->options |= gxUserFlag0;
  321.         puPrint->reduction = 50;
  322.         
  323.         // for 50% reduction, we always return faster to the application
  324.         qualityMode = gxFasterQuality;
  325.         }
  326.     else
  327.         puPrint->reduction = 100;
  328.         
  329.     // no gaps
  330.     if (wDev & kNoGaps) 
  331.         puPrint->options |= gxBiggerPages;
  332.     
  333.     // finally, store quality mode    
  334.     puPrint->qualityMode = qualityMode;
  335.     
  336.     // and we can't have any errors - because this code is too godlike.
  337.     return(noErr);
  338.     
  339. } // SD_ConvertPrintRecordTo
  340.  
  341. //<FF>
  342. /* ----------------------------------------------------------------------------    */
  343. OSErr SD_ConvertPrintRecordFrom(gxUniversalPrintRecordHdl huPrint)
  344. /*
  345.     This call takes a print record in universal format and converts it
  346.     to old style (driver specific) format.
  347.     
  348.     Note: for the ImageWriter, I'm filling in way more things than theoretically
  349.     I need to.  However, since the ImageWriter is one of the oldest print drivers,
  350.     there is much more of a chance that someone assumes something about one or
  351.     more of the fields.
  352. */
  353. {
  354.     gxUniversalPrintRecordPtr    puPrint;            // pointer to universal print record
  355.     THPrint                        hoPrint = (THPrint) huPrint;    // handle to old style print record
  356.     TPPrint                        poPrint;            // pointer to old style print record
  357.     short                        options;            // cached universal options
  358.     short                        qualityMode;        // cached universal quality mode
  359.     short                        actualCopies;        // cached universal copies
  360.     
  361.     // cache pointers for size and speed
  362.     puPrint = *huPrint;
  363.     poPrint = *hoPrint;
  364.  
  365.     // save away fields within the universal record that we'll be stomping over
  366.     // as we convert
  367.     options         = puPrint->options;
  368.     qualityMode     = puPrint->qualityMode;
  369.     actualCopies    = puPrint->actualCopies;
  370.     
  371.     poPrint->iPrVersion            = 4;        // used to be 3, but this is
  372.                                             // a new driver.  We support versions
  373.                                             // 3 and 4
  374.     poPrint->prInfo.iDev        = 0;        // always zero for the ImageWriter
  375.     
  376.     // skip remaining fields in prInfo because they are unchanged
  377.     
  378.     // determine the wDev
  379.     {
  380.     short    wDev;
  381.     
  382.     // this is the wDev value for the ImageWriter
  383.     wDev = 0x0100;
  384.     
  385.     if (puPrint->orientation == gxPortraitOrientation)
  386.         wDev |= kPortrait;
  387.     else
  388.         {
  389.         // for landscape, disable draft and force tall adjusted
  390.         if (qualityMode == gxDraftQuality)
  391.             qualityMode = gxFasterQuality;
  392.             
  393.         options |= gxPreciseBitmap;
  394.         }
  395.     
  396.     // user options
  397.     if (options & gxPreciseBitmap)
  398.         wDev |= kTallAdjusted;
  399.     if (options & gxUserFlag0)
  400.         {
  401.         wDev |= k50Percent;
  402.         qualityMode = gxFasterQuality;
  403.         }
  404.  
  405.     if (options & gxBiggerPages)
  406.         wDev |= kNoGaps;
  407.         
  408.     // if the application's resolution isn't 72 - then clearly SetRsl must have been called
  409.     // to change it.
  410.     if (poPrint->prInfo.iVRes != 72)
  411.         {
  412.         wDev |= kSetResCalled;
  413.         qualityMode = gxBestQuality; /* ?? qualityMode == gxBestQuality */
  414.         }
  415.         
  416.     if (qualityMode == gxBestQuality)
  417.         wDev |= kBest;
  418.         
  419.         
  420.     // and finally, save away that short value we worked so hard to determine
  421.     poPrint->prStl.wDev = wDev;
  422.     }
  423.  
  424.     // other fields in prStl remain the same
  425.     
  426.     poPrint->prStl.bPort     = 0;
  427.     poPrint->prStl.feed     = 1 - (puPrint->feed);
  428.     poPrint->prInfoPT.iDev     = (qualityMode == gxBestQuality) ? -768 : 0;
  429.  
  430.     // other fields in prInfoPT remain the same
  431.     {
  432.     Rect    rPage = poPrint->prInfoPT.rPage;
  433.     
  434.     // calculate some fields we don't use - in case someone really wants to look at
  435.     // them for some reason
  436.     poPrint->prXInfo.iRowBytes    = rPage.right >> 3;
  437.     poPrint->prXInfo.iBandV        = 32;
  438.     poPrint->prXInfo.iBandH        = poPrint->prXInfo.iRowBytes << 3;
  439.     poPrint->prXInfo.iDevBytes    = poPrint->prXInfo.iRowBytes * 
  440.                                     poPrint->prXInfo.iBandV + 
  441.                                     poPrint->prXInfo.iBandH;
  442.     poPrint->prXInfo.iBands        = (rPage.bottom+(poPrint->prXInfo.iBandV-1)) / poPrint->prXInfo.iBandV;
  443.     poPrint->prXInfo.bPatScale     = (qualityMode == gxBestQuality) ? -2 : 0;
  444.     poPrint->prXInfo.bUlThick     = 1;
  445.     poPrint->prXInfo.bUlOffset     = 1;
  446.     poPrint->prXInfo.bUlShadow     = 1;
  447.     poPrint->prXInfo.scan        = (poPrint->prStl.wDev & kPortrait) ? 0 : 2;
  448.     poPrint->prXInfo.bXInfoX    = 0;
  449.     }
  450.     
  451.     // other fields in prJob remain the same
  452.     poPrint->prJob.iCopies        = actualCopies;
  453.     poPrint->prJob.bJDocLoop    = (qualityMode == gxDraftQuality) ? 0 : 1;
  454.     
  455.     // this routine is so studly, there can be no errors
  456.     return(noErr);    
  457.     
  458. } // SD_ConvertPrintRecordFrom
  459.  
  460.  
  461. //<FF>
  462. /* ----------------------------------------------------------------------------    */
  463. OSErr SD_PrintRecordToJob(THPrint hPrint, gxJob theJob)
  464. /*
  465.     We convert the "tall adjusted" setting into the correct rendering option for
  466.     the job collection.
  467. */
  468. {
  469.     OSErr    anErr;
  470.     Handle     jobQualitySettingsHdl;    
  471.     
  472.     anErr = Forward_GXPrintRecordToJob(hPrint, theJob);
  473.     if (anErr == noErr)
  474.         {
  475.         long imagewriterOptions = kSuperRes;
  476.         
  477.         if ((**hPrint).prStl.wDev & kSetResCalled)
  478.             {
  479.             Collection            jobCollection = GXGetJobCollection(GXGetJob());
  480.             gxQualityInfo        *qualitySettings;
  481.     
  482.  
  483.             // get old info and replace it with final quality
  484.  
  485.  
  486.             jobQualitySettingsHdl = NewHandle(0);
  487.             anErr = MemError();
  488.             nrequire(anErr, FailedNewHandle);
  489.  
  490.             anErr = GetCollectionItemHdl (     jobCollection,
  491.                                                 gxQualityTag,
  492.                                                  gxPrintingTagID,
  493.                                                jobQualitySettingsHdl );
  494.  
  495.             if (anErr == collectionItemNotFoundErr) 
  496.                 {
  497.                 Str255            bestString, roughString;
  498.                 Size            count1, count2;
  499.                 Ptr                p;
  500.                 short            curResFile = CurResFile();
  501.                 
  502.                 UseResFile(GXGetMessageHandlerResFile());
  503.                 GetIndString( bestString, kOldQualityID, kBestString);
  504.                 GetIndString( roughString, kOldQualityID, kRoughString);
  505.                 UseResFile(curResFile);
  506.  
  507.                 SetHandleSize(jobQualitySettingsHdl,(sizeof(gxQualityInfo) + bestString[0] + roughString[0] + 2 ));
  508.                 anErr = MemError();
  509.                 nrequire( anErr, FailedSetHandleSize );
  510.                         
  511.                 qualitySettings = *((gxQualityInfo **) jobQualitySettingsHdl);
  512.                 
  513.                 qualitySettings->disableQuality = false;
  514.                 qualitySettings->defaultQuality = 1;
  515.                 qualitySettings->currentQuality = 1;
  516.                 qualitySettings->qualityCount = 2;
  517.         
  518.                 count1 = bestString[0]+1;
  519.                 p = qualitySettings->qualityNames;
  520.                 BlockMove( bestString, p, count1 );
  521.         
  522.                 count2 = roughString[0]+1;
  523.                 p += count1;
  524.                 BlockMove( roughString, p, count2 );
  525.         
  526.                 }
  527.             else
  528.                 qualitySettings = *((gxQualityInfo **) jobQualitySettingsHdl);
  529.  
  530.             (qualitySettings->currentQuality = qualitySettings->qualityCount-1);
  531.  
  532.             anErr = AddCollectionItemHdl (     jobCollection,
  533.                                             gxQualityTag,
  534.                                             gxPrintingTagID,
  535.                                             jobQualitySettingsHdl );
  536.                                                  
  537.             if (anErr == noErr)
  538.                 (void) SetCollectionItemInfo(jobCollection, gxQualityTag, gxPrintingTagID, 0x0000FFFF, gxVolatileOutputDriverCategory);
  539.                 
  540.             DisposHandle(jobQualitySettingsHdl);
  541.             }
  542.  
  543.         if ((**hPrint).prStl.wDev & kTallAdjusted)
  544.             imagewriterOptions = 0;
  545.             
  546.         if (anErr == noErr)
  547.             anErr = AddCollectionItem(GXGetJobCollection(theJob), 
  548.                         DriverCreator,
  549.                         0,
  550.                         sizeof(imagewriterOptions),
  551.                         &imagewriterOptions);
  552.         }
  553.  
  554. FailedNewHandle:        
  555.     return(anErr);
  556.  
  557. FailedSetHandleSize:
  558.     DisposHandle(jobQualitySettingsHdl);
  559.     return(anErr);
  560.     
  561. } // SD_PrintRecordToJob
  562.  
  563. //<FF>
  564. /* ----------------------------------------------------------------------------    */
  565. OSErr SD_PrValidate(    THPrint hPrint,                 // old style print record
  566.                         Boolean *wasChanged)            // was the print record changed?
  567. /*
  568.     This call validates the current print record.  It's fairly simplistic (as were
  569.     all of the old drivers) - the wDev or versions don't match the current, we call
  570.     PrintDefault.  Otherwise, we call UpdatePrintRecord - to allow the driver to sanity
  571.     check any internal fields.
  572.     
  573. */
  574. {
  575.     unsigned short    wDev;                        // note: if this were signed, the shift below would fail                    
  576.     Boolean            recordIsInvalid = true;            
  577.     OSErr            anErr = noErr;
  578.     
  579.     // check the wDev.  The upper byte must be equal to our idea of the wDev
  580.         
  581.     wDev =  (**hPrint).prStl.wDev;    
  582.     wDev >>= 8;                                // get just the device ID
  583.  
  584.     // If the device id is equal, then check the version number of the print record.
  585.     //    Only if that is also equal to the current version, will we return false (valid).
  586.         
  587.     if (     (wDev == 1) 
  588.         &&
  589.             (
  590.             ( ((**hPrint).iPrVersion) == 3 ) ||
  591.             ( ((**hPrint).iPrVersion) == 4 ) 
  592.             )
  593.         )
  594.         recordIsInvalid = false;
  595.             
  596.  
  597.     // If the the print record is not valid, then return the default print record.
  598.     // Otherwise, update the print record, based on the application's calls
  599.     // to PrGeneral.
  600.         
  601.     if (recordIsInvalid)
  602.         PrintDefault(hPrint);
  603.     else
  604.         anErr = UpdatePrintRecord(hPrint);
  605.         
  606.     *wasChanged = recordIsInvalid;
  607.     
  608.     return (anErr);
  609.     
  610. } // SD_PrValidate
  611.  
  612. //<FF>
  613. /* ----------------------------------------------------------------------------    */
  614. OSErr SD_PrJobInit(THPrint hPrint, TPPrDlg * pDlg)
  615. /*
  616.     This routine is called to initialize the job dialog.  We take the default
  617.     behavior - and then disable some of the items based on settings the user
  618.     has made:
  619.         - 50% disables all items
  620.         - apps that call SetRsl disable all items
  621.         - landscape disables draft mode
  622. */
  623. {
  624.     OSErr    anErr;
  625.     
  626.     anErr = Forward_GXPrJobInit(hPrint, pDlg);
  627.     if (anErr == noErr)
  628.         {
  629.         Boolean    disableDraft     = false;
  630.         Boolean    disableAll         = false;
  631.         short    wDev             = (**hPrint).prStl.wDev;
  632.         short    idx;
  633.         Rect    box;
  634.         Handle    item;
  635.         short    type;
  636.         
  637.         if (wDev & k50Percent)
  638.             disableAll = true;
  639.             
  640.         if (wDev & kSetResCalled)
  641.             disableAll = true;
  642.             
  643.         if (!(wDev & kPortrait))
  644.             disableDraft = true;
  645.         
  646.         // disable any controls we need to
  647.         for (idx = 6; idx <= 8; ++idx)
  648.             {
  649.             GetDItem((DialogPtr) *pDlg, idx, &type, &item, &box);
  650.             
  651.             if ( (disableAll) || ((disableDraft) && (idx == 8) ) )
  652.                 HiliteControl((ControlHandle) item, 255);
  653.             
  654.             }
  655.         }
  656.  
  657.     return(anErr);
  658.     
  659. } // SD_PrJobInit